Imports System.Collections.Generic
Imports System.Linq
Imports System.Web

#Region "using"
Imports System.Data
Imports QUANLY.DTO
#End Region
Public Class VEDAO
	Inherits AbstractDAO
	Public Sub New(strPath As [String])
		MyBase.New(strPath)
	End Sub

	Public Function SelectAll() As DataSet
		Dim ds As DataSet
		Try
			ds = New DataSet()
			MyBase.sql = "usp_VE_SelectAll"
			MyBase.FillDataSet(ds, "VE")
			Return ds
		Catch e As System.Exception
			Throw New Exception(e.Message, e.InnerException)
		Finally
			MyBase.CleanUpObject()
		End Try
	End Function

	Public Function SelectByID(id As Integer) As DataSet
		Dim ds As DataSet
		Try
			ds = New DataSet()
			MyBase.sql = "usp_VE_SelectByID"
			MyBase.InitializeCommand()
			MyBase.AddParameter("@ID", SqlDbType.Int, 1000, id)
			MyBase.FillDataSet(ds, "VE")
			Return ds
		Catch e As System.Exception
			Throw New Exception(e.Message, e.InnerException)
		Finally
			MyBase.CleanUpObject()
		End Try
	End Function

	Public Function Insert(obj As VEDTO) As Boolean
		Try
			MyBase.sql = "usp_VE_Insert"
			MyBase.InitializeCommand()
			MyBase.AddParameter("@IDLoaiVe", SqlDbType.Int, 1000, obj.IDLoaiVe)
            MyBase.AddParameter("@IDKhachHang", SqlDbType.Int, 1000, obj.IDKhachHang)
            MyBase.AddParameter("@IDTour", SqlDbType.Int, 1000, obj.IDTour)
            MyBase.AddParameter("@SoGhe", SqlDbType.Int, 1000, obj.soghe)
			Return ExecuteStoredProcedure()
		Catch
			Return False
		End Try
	End Function

	Public Function Update(obj As VEDTO) As Boolean
		Try
			MyBase.sql = "usp_VE_Update"
			MyBase.InitializeCommand()
			MyBase.AddParameter("@ID", SqlDbType.Int, 1000, obj.ID)
			MyBase.AddParameter("@IDLoaiVe", SqlDbType.Int, 1000, obj.IDLoaiVe)
            MyBase.AddParameter("@IDKhachHang", SqlDbType.Int, 1000, obj.IDKhachHang)
            MyBase.AddParameter("@IDTour", SqlDbType.Int, 1000, obj.IDTour)
            MyBase.AddParameter("@SoGhe", SqlDbType.Int, 1000, obj.soghe)
			Return ExecuteStoredProcedure()
		Catch
			Return False
		End Try
	End Function

	Public Function Delete(id As Integer) As Boolean
		Try
			MyBase.sql = "usp_VE_Delete"
			MyBase.InitializeCommand()
			MyBase.AddParameter("@ID", SqlDbType.Int, 1000, id)
			Return ExecuteStoredProcedure()
		Catch
			Return False
		End Try
	End Function

    Public Function DeleteByIDTour(ByVal id As Integer) As Boolean
        Try
            MyBase.sql = "usp_VE_DeleteByIDTour"
            MyBase.InitializeCommand()
            MyBase.AddParameter("@IDTour", SqlDbType.Int, 1000, id)
            Return ExecuteStoredProcedure()
        Catch
            Return False
        End Try
    End Function

	Public Function SelectByIDLoaiVe(idloaive As Integer) As DataSet
		Dim ds As DataSet
		Try
			ds = New DataSet()
			MyBase.sql = "usp_VE_SelectByIDLoaiVe"
			MyBase.InitializeCommand()
			MyBase.AddParameter("@IDLoaiVe", SqlDbType.Int, 1000, idloaive)
			MyBase.FillDataSet(ds, "VE")
			Return ds
		Catch e As System.Exception
			Throw New Exception(e.Message, e.InnerException)
		Finally
			MyBase.CleanUpObject()
		End Try
	End Function

	Public Function SelectByIDKhachHang(idkhachhang As Integer) As DataSet
		Dim ds As DataSet
		Try
			ds = New DataSet()
			MyBase.sql = "usp_VE_SelectByIDKhachHang"
			MyBase.InitializeCommand()
			MyBase.AddParameter("@IDKhachHang", SqlDbType.Int, 1000, idkhachhang)
			MyBase.FillDataSet(ds, "VE")
			Return ds
		Catch e As System.Exception
			Throw New Exception(e.Message, e.InnerException)
		Finally
			MyBase.CleanUpObject()
		End Try
    End Function

    Public Function SelectByIDTour(ByVal idtour As Integer) As DataSet
        Dim ds As DataSet
        Try
            ds = New DataSet()
            MyBase.sql = "usp_VE_SelectByIDTour"
            MyBase.InitializeCommand()
            MyBase.AddParameter("@IDTour", SqlDbType.Int, 1000, idtour)
            MyBase.FillDataSet(ds, "VE")
            Return ds
        Catch e As System.Exception
            Throw New Exception(e.Message, e.InnerException)
        Finally
            MyBase.CleanUpObject()
        End Try
    End Function

    Public Function SelectBysoghe(ByVal soghe As Integer) As DataSet
        Dim ds As DataSet
        Try
            ds = New DataSet()
            MyBase.sql = "usp_VE_SelectBysoghe"
            MyBase.InitializeCommand()
            MyBase.AddParameter("@soghe", SqlDbType.Int, 1000, soghe)
            MyBase.FillDataSet(ds, "VE")
            Return ds
        Catch e As System.Exception
            Throw New Exception(e.Message, e.InnerException)
        Finally
            MyBase.CleanUpObject()
        End Try
    End Function


End Class
